﻿using Cart.NguoiDungSrv;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cart
{
    public partial class DanhSachNguoiDung : VdcInc.vdcAJAXPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            #region check quyen
            var user = Session["nsd"] as NguoiDung;
            if (user != null)
            {
                if (user.Quyen != 1) ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Không có quyền truy cập !'); window.location='" + Request.ApplicationPath + "TrangChu.aspx';", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Không có quyền truy cập !'); window.location='" + Request.ApplicationPath + "TrangChu.aspx';", true);
            }

            #endregion check quyen
            using (var ndService = new NguoiDungServiceClient())
            {
                var nguoidungmodel = ndService.DanhSachNguoiDung(0);
                lvDanhSach.DataSource = nguoidungmodel;
                lvDanhSach.DataBind();
            }
        }
        public string XoaNguoiDung(string strNguoiDungId)
        {
            using (var ndService = new NguoiDungServiceClient())
            {
                var nguoidungmodel = new NguoiDung();
                nguoidungmodel.Id = Convert.ToInt64(strNguoiDungId);
                var result = ndService.CapNhatNguoiDung(nguoidungmodel);
                return "Xóa " + result;
            }
        }
    }
}